package cn.fl.mcr.transform;

import cn.fl.mcr.vo.McrSourcePopCountVO;
import cn.lionbridgecapital.loan.model.dto.McrSourcePopCountDTO;
import cn.lionbridgecapital.loan.model.po.McrSourcePopCount;
import cn.lionbridgecapital.loan.model.utils.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

/**
 * @author yangqh521
 * @date 2020/4/24
 * @desp
 */
public class McrSourcePopCountVOTransform {

    public static McrSourcePopCountVO baseoToVO(McrSourcePopCountDTO dto){
        McrSourcePopCountVO vo = null;
        if(dto != null){
            vo = new McrSourcePopCountVO();
            vo.setId(dto.getId());
            vo.setSourceId(dto.getSourceId());
            vo.setSourceNm(dto.getSourceNm());
            vo.setLoanCount(dto.getLoanCount());
            vo.setLoanAmt(dto.getLoanAmt());
            vo.setBrokerage(dto.getLoanCount() != null ? dto.getLoanCount() * 100L : 0L);
        }
        return vo;
    }

    public static List<McrSourcePopCountVO> toVOList(List<McrSourcePopCountDTO> dtoList){
        List<McrSourcePopCountVO> voList = new ArrayList<>();
        if(CollectionUtils.isNotEmpty(dtoList)){
            Consumer<McrSourcePopCountDTO> consumer = dto -> voList.add(baseoToVO(dto));
            dtoList.forEach(consumer);
        }
        return voList;
    }

}
